package com.film.admincontroller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.film.domain.Performer;
import com.film.service.PerformerService;
import com.film.service.impl.PerformerServiceImpl;

@WebServlet("/adminPerformer.do")
public class SelectPerformerAdminController extends HttpServlet{
	PerformerService  performerService = new PerformerServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		int Page = 0;
		int count = 1;
		int selectPageNum = 10;
		int firstPage;
		if(req.getParameter("firstPage")!=null) {
			Page = Integer.parseInt(req.getParameter("firstPage"));
			count = Integer.parseInt(req.getParameter("firstPage"));
			firstPage = (Page-1)*selectPageNum;
		}else {
			firstPage = 0;
		}
		List<Performer> performerPage = performerService.selectPerformer(firstPage, selectPageNum);
//		List<Performer> performerList = performerService.selectPerformer();
		List pageNum = performerService.pageNum();
		HttpSession session = req.getSession();
		session.setAttribute("performerPageNum", count);
		session.setAttribute("performerPage",performerPage);
//		session.setAttribute("performerList", performerList);
		session.setAttribute("pageNum", pageNum);
		resp.sendRedirect("/film/admin_jsp/performer.jsp");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req,resp);
	}
	
}
